package com.doit.day05

import com.doit.day05.AnyThings._

import scala.language.implicitConversions

object _10_隐式转换 {
  def main(args: Array[String]): Unit = {
/*    implicit val abc = 10
//    implicit val abcd = 20
    implicit val bcd = "20"
    //隐式参数
    def add(implicit a:Int, b:String)={
      a+b.toInt
    }
    def add1(a:Int)( c:Int)(implicit b:String)={
      a+b.toInt
    }*/
    //隐式方法
    implicit def str2Bird1(str:Int)={
      new Bird
    }
    implicit def str2Bird(str:String)={
      new Bird
    }
    implicit def int2String(i:Int)={
      "a"
    }
    implicit class Snake(ant:Ant){
      def eatElephant()={
        println("我可以吃大象")
      }
    }

//    1 to 10
    "pig".canFly()

    1.canFly()
    //练习 ==》 我想让int类型用用字符串中的concat 拼接得方法

    println(1.concat("hello"))

    val ant: Ant = new Ant
    ant.eatElephant()



  }
}
class Ant






